﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LongNet.Config
{
    /// <summary>
    /// The file config manager(thread-safe) interface to load or save configs.
    /// It manages the config entities that inherit the <see cref="FileConfigEntity"/>.
    /// </summary>
    /// <typeparam name="T">The type which inherits the <see cref="FileConfigEntity"/>.</typeparam>
    public interface IFileConfigManager<T> where T : FileConfigEntity, new()
    {
        /// <summary>
        /// Occurs when the config entity gets changed.
        /// </summary>
        event AppConfigChangedEventHandler ConfigChanged;

        /// <summary>
        /// Occurs when the config entity fails to get reloaded.
        /// </summary>
        event AppConfigReloadFailedEventHandler ConfigReloadFailed;

        /// <summary>
        /// Gets the path of current config file.
        /// </summary>
        string ConfigPath { get; }


        /// <summary>
        /// Gets the current config entity.
        /// </summary>
        T GetConfig();

        /// <summary>
        /// Saves the current config to config file.
        /// </summary>
        /// <returns>True if the save was succesful.</returns>
        void SaveConfig();

        /// <summary>
        /// Backups the config to the specified path.
        /// </summary>
        /// <param name="backupPath">The path to save the config file.</param>
        void BackupConfig(string backupPath);

        /// <summary>
        /// Restores the config from the specified path.
        /// </summary>
        /// <param name="restorePath">The path to load the config file.</param>
        void RestoreConfig(string restorePath);
    }
}
